package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("ssl");
        list.add("chengsuo");
        list.add("xuzhijie");
        list.add("xiaoyu");
//        System.out.println(list);
//        Collections.sort(list);
//        System.out.println(list);
//        Collections.reverse(list);
//        System.out.println(list);
//        Collections.sort(list,Collections.reverseOrder());
//        System.out.println(list);


          List<String> list2 = new ArrayList<>();
          list2.add("孙双良");
          list2.add("汪汪汪");
          list2.add("狗叫");
          System.out.println(list2);
          Collections.sort(list2);
          System.out.println("这是排序后的数据"+list2);
          Collections.reverse(list2);
          System.out.println("这是反转后的数据"+list2);
          Collections.sort(list2,(o1, o2)->o2.length() - o1.length());
          System.out.println("这是按照长度排序后的数据"+list2);

    }
}
